package com.xiaoshuidi.cloud.module.rooms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.iot.vo.RoomDiviceAssociationVo;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.nonIntelligentDevice.vo.DepRoomDevicePriceVO;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.nonIntelligentDevice.vo.RoomDevicePriceAssociationVO;
import com.xiaoshuidi.cloud.module.rooms.mapper.RoomDevicePriceAssociationMapper;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomDevicePriceAssociation;
import com.xiaoshuidi.cloud.module.rooms.repository.IotRoomDevicePriceAssociationRepository;
import com.xiaoshuidi.cloud.module.rooms.service.IRoomDevicePriceAssociationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 水电煤阶梯价格关联表 服务实现类
 * </p>
 *
 * @author James
 * @since 2023-06-07
 */
@Service
public class RoomDevicePriceAssociationServiceImpl extends ServiceImpl<RoomDevicePriceAssociationMapper, RoomDevicePriceAssociation> implements IRoomDevicePriceAssociationService {
    @Autowired
    RoomDevicePriceAssociationMapper roomDevicePriceAssociationMapper;

    @Autowired
    IotRoomDevicePriceAssociationRepository roomDevicePriceAssociationRepository;

    @Override
    public List<RoomDiviceAssociationVo> getAssociationList(Long devicePriceId) {
        QueryWrapper<RoomDevicePriceAssociation> wrapper = new QueryWrapper();
        wrapper.eq("rsdpa.device_price_id", devicePriceId);
        wrapper.eq("rsdpa.deleted", false);
        return roomDevicePriceAssociationMapper.getRoomDeviceAssociationList(wrapper);
    }

    @Override
    public CommonResult<String> setPriceToRoom(RoomDevicePriceAssociationVO roomDevicePriceAssociationVO) {
        return roomDevicePriceAssociationRepository.setPriceToRoom(roomDevicePriceAssociationVO);
    }

    @Override
    public CommonResult<List<DepRoomDevicePriceVO>> findAllRoomId(long devicePriceId) {
        return roomDevicePriceAssociationRepository.findAllRoomId(devicePriceId);
    }
}
